package com.io.page;

import java.io.File;
import java.io.IOException;

/**
 * Created by as on 2016/11/17.
 */
public class File_Manage {
    public static void main(String[] args) throws IOException {
        File dir_Books = new File("D:/Boos");
        File file_Book1 = new File(dir_Books, "book1.txt");

        if (!dir_Books.exists()){
            System.out.println(dir_Books.getName() + "是否建立成功");
            System.out.println(dir_Books.mkdirs());
        }else{
            System.out.println(dir_Books.getName() + "已存在");
        }

        if (!file_Book1.exists()){
            System.out.println(file_Book1.getName() + "是否建立成功");
            System.out.println(file_Book1.createNewFile());
        }else{
            System.out.println(file_Book1.getName() + "已存在");
        }

        File file_Book2 = new File(file_Book1.getParent(), "Book2.txt");
        System.out.println(file_Book1.getName() + "文件改名为" + file_Book2.getName());

        System.out.println("是否修改成功");
        System.out.println(file_Book1.renameTo(file_Book2));

        System.out.println(file_Book2.getName() + "是否删除成功");
        System.out.println(file_Book2.delete());

        System.out.println(dir_Books.getName() + "是否删除成功");
        System.out.println(dir_Books.delete());

    }
}
